#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
using namespace std;
#define prnt(v) for(auto i:v)cout<<i<<" " ; cout<<endl;
#define trnf(s,v) for(auto i:s) v.push_back(i);
#define all(v) v.begin(),v.end()
#define inp(v,n) vector<int> v(n); for(int i=0; i<n;i++)cin>>v[i];
const int mod = 1000000007;
const int N = 2000010;
const int inf = 1e18;
signed main(){
fastIO;
int t; cin >> t;
while(t--){
int n, k; cin >> n >> k;
if(n == 4 && k == 3){
cout << -1 << endl;
}
else if(k == n - 1){
cout << n - 2 << " " << n - 1 << endl;
cout << 1 << " " << n - 3 << endl;
int i = 0, j = n - 1;
while(j - i > 0){
if(j == n -1 || j == n - 2 || j == n - 3 || i == 1) {i++; j--;continue;}
cout << i << " " << j << endl;
i++; j--;
}
cout << 0 << " " << 2 << endl;
}
else{
cout << k << " " << n - 1 << endl;
int i = 0, j = n - 1;
while(j - i > 0){
if(i == k || i == n - 1 || j == k || j == n - 1){
i++;
j--;
continue;
}
cout << i << " " << j << endl;
i++; j--;
}
if(k != 0){
int x , y;
if(k >= (n/2)){
x = n - k - 1;
y = 0;
}
else{
x = 0;
y = n - (k + 1);
}
cout << x << " " << y << endl;
}
}
}
}
450A - Jzzhu and Children | 546A - Soldier and Bananas |
32B - Borze | 1651B - Prove Him Wrong |
381A - Sereja and Dima | 41A - Translation |
1559A - Mocha and Math | 832A - Sasha and Sticks |
292B - Network Topology | 1339A - Filling Diamonds |
910A - The Way to Home | 617A - Elephant |
48A - Rock-paper-scissors | 294A - Shaass and Oskols |
1213A - Chips Moving | 490A - Team Olympiad |
233A - Perfect Permutation | 1360A - Minimal Square |
467A - George and Accommodation | 893C - Rumor |
227B - Effective Approach | 1534B - Histogram Ugliness |
1611B - Team Composition Programmers and Mathematicians | 110A - Nearly Lucky Number |
1220B - Multiplication Table | 1644A - Doors and Keys |
1644B - Anti-Fibonacci Permutation | 1610A - Anti Light's Cell Guessing |
349B - Color the Fence | 144A - Arrival of the General |